package main

import "fmt"

// Person 结构体
type Person struct {
	Name   string
	Age    int
	Adders string
}

func main() {
	//数组结构体
	users2 := []Person{
		{
			Name:   "张三",
			Age:    15,
			Adders: "hellish",
		},
		{
			Name:   "李四",
			Age:    25,
			Adders: "北京市",
		},
	}
	users2[0].Name = "王五"
	//✅ 正确写法（使用指针）修改
	for i := range users2 {
		users2[i].Age += 1 // 直接修改原切片元素
	}
	for _, user := range users2 {
		fmt.Printf("用户名：%s,年龄：%d,地址：%s\n", user.Name, user.Age, user.Adders)
	}
}
